<template>
	<view class="content">
		login
		<text @click="goTopage">点击跳转分包页面</text>
		<view @click="goTopageHome">点击跳转home页面,测试相关依赖项</view>
		<div>主包图片测试1</div>
		<image src='/static/images/logo.png'></image>
		<view @click="scanPdf" class="checkStyle">查看pdf</view>
		<view @click="goToAudio" class="checkStyle">录制视频页面</view>
		<view @click="signPage" class="checkStyle">手写签名页面</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'home'
			};
		},
		onLoad() {
		},
		methods: {

			goTopage() {
				console.log('222')
				// this.$Router.push({
				// 	path:'/subpages',
				// 	query:{
				// 		id:123
				// 	}
				// })
				this.$Router.push({
					// path:'/subpages',
					name: 'subpages',
					params: {
						id: 123
					}
				})
			},
			goToAudio(){
					this.$Router.push('/audio')
			},
			goTopageHome() {
				this.$Router.push('/home')
			},
			signPage(){
				this.$Router.push('/sign')
			},
			// 预览pdf
			scanPdf() {
				// 根据手机类型判断
				const pdfUrl = '/test.pef'
				uni.getSystemInfo({
					success: res => {
						console.log(res.platform, "当前的手机型号")
						if (res.platform === "android") {
							this.openPdf(pdfUrl)
						} else {
							this.$Router.push({
								name: 'subpages',
								params: {
									pdfUrl
								}
							})
						}
					}
				})
			},
			openPdf(url) {
				uni.showLoading({
					mask: true,
					title: "",
				})
				wx.downloadFile({
					url: url,
					success: function(resinfo) {
						console.log("pdf协议文件已下载")
						let path = resinfo.tempFilePath
						wx.openDocument({
							filePath: path,
							fileType: "pdf",
							success: function(rest) {
								console.log("打开文件成功")
								console.log(rest)
								uni.hideLoading()
							},
							fail: function(error) {
								uni.hideLoading()
								uni.showModal({
									title: "温馨提示",
									content: "打开文件失败",
									showCancel: false,
								})
							},
						})
					},
					fail: function(err) {
						uni.hideLoading()
						uni.showModal({
							title: "温馨提示",
							content: "下载文件失败",
							showCancel: false,
						})
					},
				})
			},
		}
	};
</script>

<style lang="less" scoped>
	.content {
		text-align: center;
		height: 400px;
		margin-top: 200px;
		font-size:20px;
		font-weight: bold;
		width: 100%;
	}

	.checkStyle {
		font-size: 20px;
		height: 30px;
	}
</style>